using System;

namespace UnitTesting.Fixturing
{
	class SimpleTypeRandom : ISimpleTypeGenerator
	{
		internal int InclusiveMin { get; private set; }

		internal int ExclusiveMax { get; private set; }

		readonly Random _random = new Random();

		internal SimpleTypeRandom()
			: this(SimpleValueProvider.INCLUSIVE_MIN, SimpleValueProvider.EXCLUSIVE_MAX)
		{
		}

		internal SimpleTypeRandom(int inclusiveMin, int exclusiveMax)
		{
			InclusiveMin = inclusiveMin;
			ExclusiveMax = exclusiveMax;
			SimpleValueProvider.EnsureIsValidRange(InclusiveMin, ExclusiveMax);
		}

		public int Next(Type simpleType)
		{
			Ensure.IsNotNull(() => simpleType);
			return _random.Next(InclusiveMin, ExclusiveMax);
		}
	}
}